﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DalatCooking.Core;
using System.Web.SessionState;
using System.Web;
namespace DalatCooking.Core.Helper
{
    public static  class SessionHelper
    {
        // For nomarl user


        public static void SetPersonLogged(this  HttpSessionState session, Person p)
        {
           session["PersonLogged"] = p;
        }
        public static Person GetPersonLogged(this HttpSessionState session) 
        {
            return session["PersonLogged"] as Person;
        }
        public static void RemovePerssonLogged(this HttpSessionState session)
        {
            session.Remove("PersonLogged");
        }
         
       
        public static void SetShoppingCart(this HttpSessionState session, Cart c)
        {
            session["ShoppingCart"] = c;
        }
        public static Cart GetShoppingCart(this HttpSessionState session)
        {
            return session["ShoppingCart"] as Cart;
        }
        public static void RemoveShoppingCart(this HttpSessionState session)
        {
            session.Remove("ShoppingCart");
        }
        // And more ...

        // Use for MVC
        public static void SetPersonLogged(this  HttpContextBase context, Person p)
        {
            context.Session["PersonLogged"] = p;
        }
        public static Person GetPersonLogged(this HttpContextBase context)
        {
            return context.Session["PersonLogged"] as Person;
        }
        public static void RemovePerssonLogged(this HttpContextBase context)
        {
            context.Session.Remove("PersonLogged");
        }

        public static void SetShoppingCart(this HttpContextBase context, Cart c)
        {
            context.Session["ShoppingCart"] = c;
        }
        public static Cart GetShoppingCart(this HttpContextBase context)
        {
            return context.Session["ShoppingCart"] as Cart;
        }
        public static void RemoveShoppingCart(this HttpContextBase context)
        {
            context.Session.Remove("ShoppingCart");
        }
    }
}
